<template>
  <header id="navbar">
    <div id="navbar-container" class="boxed">
      <!--Brand logo & name-->
      <!--================================-->
      <div class="navbar-header">
        <a href="index.html" class="navbar-brand">
          <img src="static/img/logo.png" alt="Nifty Logo" class="brand-icon">
          <div class="brand-title">
            <span class="brand-text">Nifty</span>
          </div>
        </a>
      </div>
      <!--================================-->
      <!--End brand logo & name-->
      <!--Navbar Dropdown-->
      <!--================================-->
      <div class="navbar-content clearfix">
        <ul class="nav navbar-top-links pull-left">
          <!--Navigation toogle button-->
          <!--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
          <li class="tgl-menu-btn">
            <a class="mainnav-toggle" href="#">
              <i class="demo-pli-view-list"></i>
            </a>
          </li>
        </ul>
        <ul class="nav navbar-top-links pull-right">
          <!--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
          <li id="dropdown-user" class="dropdown">
            <a href="#" data-toggle="dropdown" class="dropdown-toggle text-right">
              <span class="pull-right">
                <img class="img-circle img-user media-object" :src="baseUrl+useri.img" alt="Profile Picture">
                <!-- <i class="demo-pli-male ic-user"></i> -->
              </span>
              <div class="username hidden-xs">{{useri.Username}}</div>
            </a>
            <div class="dropdown-menu dropdown-menu-md dropdown-menu-right panel-default">
              <!-- Dropdown heading  -->
              <!-- <div class="pad-all bord-btm">
                <p class="text-main mar-btm">
                  <span class="text-bold">750GB</span> of 1,000GB Used</p>
                <div class="progress progress-sm">
                  <div class="progress-bar" style="width: 70%;">
                    <span class="sr-only">70%</span>
                  </div>
                </div>
              </div> -->
              <!-- User dropdown menu -->
              <ul class="head-list">
                <!-- <li>
                  <a href="#">
                    <i class="demo-pli-male icon-lg icon-fw"></i> Profile
                  </a>
                </li>
                <li>
                  <a href="#">
                    <span class="badge badge-danger pull-right">9</span>
                    <i class="demo-pli-mail icon-lg icon-fw"></i> Messages
                  </a>
                </li>
                <li>
                  <a href="#">
                    <span class="label label-success pull-right">New</span>
                    <i class="demo-pli-gear icon-lg icon-fw"></i> Settings
                  </a>
                </li>
                <li>
                  <a href="#">
                    <i class="demo-pli-information icon-lg icon-fw"></i> Help
                  </a>
                </li> -->
                <li class="font-160" @click="logout">
                  <a href="#">
                    <i class="ion-power"></i> &nbsp;&nbsp;&nbsp;&nbsp;注销登录
                  </a>
                </li>
              </ul>
              <!-- Dropdown footer -->
              <!--  <div class="pad-all text-right">
                <a href="pages-login.html" class="btn btn-primary">
                  <i class="demo-pli-unlock"></i> Logout
                </a>
              </div> -->
            </div>
          </li>
          <!--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
          <!--End user dropdown-->
          <li>
            <a href="#" class="aside-toggle navbar-aside-icon">
              <i class="pci-ver-dots"></i>
            </a>
          </li>
        </ul>
      </div>
      <!--================================-->
      <!--End Navbar Dropdown-->
    </div>
  </header>
</template>
<script>
import { mapState } from 'vuex'
export default {
  created() {},
  data() {
    return {
      datas: []
    }
  },
  mounted() {
    //显示注销登录弹框
    var userT = 0;
    $("#dropdown-user").click(function() {
      if (userT == 0) {
        $("#dropdown-user").children().eq(1).show();
        userT = 1;
      } else {
        $("#dropdown-user").children().eq(1).hide();
        userT = 0;
      }
    });
    $(document).click(function(e) {
      $("#dropdown-user").children().eq(1).hide();
      userT = 0;
    });
  },
  methods: {
    //退出登录
    logout() {
      let userinfo = { userinfo: {}, rules: [] };
      this.$store.commit('setUserinfo', userinfo);
      this.$router.push({ name: 'login' })
    }
  },
  computed: {
    ...mapState({
      useri: state => state.userinfo.userinfo,
    })
  }
}

</script>
<style>
.dropdown-menu-md {
  min-width: 100%;
}

</style>
